package chapter2_3;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)	//为了在测试开始的时候自动创建Spring的应用上下文。
@ContextConfiguration(locations="config.xml")
public class CDPlayerTest {
	@Autowired
	private CDPlayerImpl player;
	
	@Test	//断言cd不为null
	public void cdShouldNotBeNull() {
		assertNotNull(player);	// CDPlayerConfig中包含ComponentScan, 因此CompactDist类能被扫描到
	}
	
	@Test
	public void playRightSong() {
		assertEquals("SgtPeppers TheBeatles", player.play());
	}
}
